<?php
namespace app\api\controller;
use think\Controller;
use app\api\model\Venue;
use app\api\model\Favorite as Fas;
//我的收藏
class Favorite extends Co2{
    public function selectLists(Venue $ve){
        //session('user_id',1);
        $user_id=session('user_id');
        $res= $ve->VenueDetailDuo($user_id);
       //这里注入的是场地的一个出信息 根据相应页面需要取出相应的数据即可
       //然后点击调用Venue控制器 和搜索周边点击传递的ID一样
        
    }
    //单个删除收藏
    public function delete(Fas $f){
        //session('user_id',1);
        
        $user_id=session('user_id');
        $id=empty(input('get.place_id'))?ajaxReturn2(-1,'place_id is miss','fuck'):input('get.place_id');
       $res=$f->deleteWhere($user_id,$id);
       if($res){
           ajaxReturn2(1,'dele sucess','');
       }else{
           ajaxReturn2(0,'delet failed',$id);
       }
    }
    //清空删除批量删除
    public function deleteAll(Fas $f){
        session('user_id',1);
        $user_id=session('user_id');
       $res=$f->deleteAll($user_id);
       if($res){
           ajaxReturn2(1,'deleteAll sucess','');
       }else{
           ajaxReturn2(0,'deleteAll failed',$user_id);
       }
        
    }
    //点击收藏
    public function add(Fas $f){
       $data=input('get.');
       $user_id=session('user_id');
       $data['user_id']=$user_id;
       $res=$f->add($data);
       if($res){
            ajaxReturn2(1,'add sucess','');
       }else{
           ajaxReturn2(0,'fa failed',$data);
       }
    }
    public function deletes(Fas $f){
        $id=input('get.id');
       // echo $id;
       $res=$f->deletes($id);
       //echo session('user_id');
       if($res){
           ajaxReturn2(1,'删除成功','');
           
       }else{
           ajaxReturn2(0,'删除失败',$id);
       }
    }
}